/*
 * Powered By [leyvi]
 * Since 2014 - 2016
 */


var memberLog = {};
var common = require('../../utils/commonUtils');
//db转换成model
memberLog.dbConvertModel = function(db){
	var memberLog = {}; 
	if(common.isNotBlank(db.id)) memberLog.id = db.id;	
	if(common.isNotBlank(db.member_id)) memberLog.memberId = db.member_id;	
	if(common.isNotBlank(db.type)) memberLog.type = db.type;	
	if(common.isNotBlank(db.target_id)) memberLog.targetId = db.target_id;	
	if(common.isNotBlank(db.log_time)){
		memberLog.logTime = db.log_time;
		memberLog.logTimeStr = db.log_time.format('yyyy-MM-dd hh:mm');
	} 		
	if(common.isNotBlank(db.create_time)){
		memberLog.createTime = db.create_time;
		memberLog.createTimeStr = db.create_time.format('yyyy-MM-dd hh:mm');
	} 		
	if(common.isNotBlank(db.update_time)){
		memberLog.updateTime = db.update_time;
		memberLog.updateTimeStr = db.update_time.format('yyyy-MM-dd hh:mm');
	} 		
	if(common.isNotBlank(db.bak1)) memberLog.bak1 = db.bak1;	
	if(common.isNotBlank(db.bak2)) memberLog.bak2 = db.bak2;	
	if(common.isNotBlank(db.bak3)) memberLog.bak3 = db.bak3;	
	if(typeof db.bak4 != "undefined") memberLog.bak4 = db.bak4;
	if(typeof db.bak5 != "undefined") memberLog.bak5 = db.bak5;
	if(common.isNotBlank(db.bak6)) memberLog.bak6 = db.bak6;	
	if(common.isNotBlank(db.bak7)) memberLog.bak7 = db.bak7;	
	if(common.isNotBlank(db.bak8)) memberLog.bak8 = db.bak8;	
	if(typeof db.bak9 != "undefined") memberLog.bak9 = db.bak9;
	if(typeof db.bak10 != "undefined") memberLog.bak10 = db.bak10;
	return memberLog;
};

//model转换成db
memberLog.modelConvertDb = function(obj){
	var db = {}; 
	if(common.isNotBlank(obj.id)) db.id = obj.id;
	if(common.isNotBlank(obj.memberId)) db.member_id = obj.memberId;
	if(common.isNotBlank(obj.type)) db.type = obj.type;
	if(common.isNotBlank(obj.targetId)) db.target_id = obj.targetId;
	if(common.isNotBlank(obj.logTime)) db.log_time = obj.logTime;
	if(common.isNotBlank(obj.createTime)) db.create_time = obj.createTime;
	if(common.isNotBlank(obj.updateTime)) db.update_time = obj.updateTime;
	if(common.isNotBlank(obj.bak1)) db.bak1 = obj.bak1;
	if(common.isNotBlank(obj.bak2)) db.bak2 = obj.bak2;
	if(common.isNotBlank(obj.bak3)) db.bak3 = obj.bak3;
	if(typeof obj.bak4 != "undefined") db.bak4 = obj.bak4;
	if(typeof obj.bak5 != "undefined") db.bak5 = obj.bak5;
	if(common.isNotBlank(obj.bak6)) db.bak6 = obj.bak6;
	if(common.isNotBlank(obj.bak7)) db.bak7 = obj.bak7;
	if(common.isNotBlank(obj.bak8)) db.bak8 = obj.bak8;
	if(typeof obj.bak9 != "undefined") db.bak9 = obj.bak9;
	if(typeof obj.bak10 != "undefined") db.bak10 = obj.bak10;
	return db;
};

memberLog.initPostReq = function(req){
	var memberLog = {};
	if(req.body.id != undefined){
		(typeof req.body.id != 'string') ? (memberLog.id = req.body.id) : (memberLog.id = req.body.id.trim());
	}
	if(req.body.memberId != undefined){
		(typeof req.body.memberId != 'string') ? (memberLog.memberId = req.body.memberId) : (memberLog.memberId = req.body.memberId.trim());
	}
	if(req.body.type != undefined){
		(typeof req.body.type != 'string') ? (memberLog.type = req.body.type) : (memberLog.type = req.body.type.trim());
	}
	if(req.body.targetId != undefined){
		(typeof req.body.targetId != 'string') ? (memberLog.targetId = req.body.targetId) : (memberLog.targetId = req.body.targetId.trim());
	}
	if(req.body.logTime != undefined){
		(typeof req.body.logTime != 'string') ? (memberLog.logTime = req.body.logTime) : (memberLog.logTime = req.body.logTime.trim());
	}
	if(req.body.createTime != undefined){
		(typeof req.body.createTime != 'string') ? (memberLog.createTime = req.body.createTime) : (memberLog.createTime = req.body.createTime.trim());
	}
	if(req.body.updateTime != undefined){
		(typeof req.body.updateTime != 'string') ? (memberLog.updateTime = req.body.updateTime) : (memberLog.updateTime = req.body.updateTime.trim());
	}
	if(req.body.bak1 != undefined){
		(typeof req.body.bak1 != 'string') ? (memberLog.bak1 = req.body.bak1) : (memberLog.bak1 = req.body.bak1.trim());
	}
	if(req.body.bak2 != undefined){
		(typeof req.body.bak2 != 'string') ? (memberLog.bak2 = req.body.bak2) : (memberLog.bak2 = req.body.bak2.trim());
	}
	if(req.body.bak3 != undefined){
		(typeof req.body.bak3 != 'string') ? (memberLog.bak3 = req.body.bak3) : (memberLog.bak3 = req.body.bak3.trim());
	}
	if(req.body.bak4 != undefined){
		(typeof req.body.bak4 != 'string') ? (memberLog.bak4 = req.body.bak4) : (memberLog.bak4 = req.body.bak4.trim());
	}
	if(req.body.bak5 != undefined){
		(typeof req.body.bak5 != 'string') ? (memberLog.bak5 = req.body.bak5) : (memberLog.bak5 = req.body.bak5.trim());
	}
	if(req.body.bak6 != undefined){
		(typeof req.body.bak6 != 'string') ? (memberLog.bak6 = req.body.bak6) : (memberLog.bak6 = req.body.bak6.trim());
	}
	if(req.body.bak7 != undefined){
		(typeof req.body.bak7 != 'string') ? (memberLog.bak7 = req.body.bak7) : (memberLog.bak7 = req.body.bak7.trim());
	}
	if(req.body.bak8 != undefined){
		(typeof req.body.bak8 != 'string') ? (memberLog.bak8 = req.body.bak8) : (memberLog.bak8 = req.body.bak8.trim());
	}
	if(req.body.bak9 != undefined){
		(typeof req.body.bak9 != 'string') ? (memberLog.bak9 = req.body.bak9) : (memberLog.bak9 = req.body.bak9.trim());
	}
	if(req.body.bak10 != undefined){
		(typeof req.body.bak10 != 'string') ? (memberLog.bak10 = req.body.bak10) : (memberLog.bak10 = req.body.bak10.trim());
	}
	return memberLog;
};

memberLog.initGetReq = function(req){
	var memberLog = {};
	if(req.query.id != undefined){	
		(typeof req.query.id != 'string') ? (memberLog.id = req.query.id) : (memberLog.id = req.query.id.trim());
	}
	if(req.query.memberId != undefined){	
		(typeof req.query.memberId != 'string') ? (memberLog.memberId = req.query.memberId) : (memberLog.memberId = req.query.memberId.trim());
	}
	if(req.query.type != undefined){	
		(typeof req.query.type != 'string') ? (memberLog.type = req.query.type) : (memberLog.type = req.query.type.trim());
	}
	if(req.query.targetId != undefined){	
		(typeof req.query.targetId != 'string') ? (memberLog.targetId = req.query.targetId) : (memberLog.targetId = req.query.targetId.trim());
	}
	if(req.query.logTime != undefined){	
		(typeof req.query.logTime != 'string') ? (memberLog.logTime = req.query.logTime) : (memberLog.logTime = req.query.logTime.trim());
	}
	if(req.query.createTime != undefined){	
		(typeof req.query.createTime != 'string') ? (memberLog.createTime = req.query.createTime) : (memberLog.createTime = req.query.createTime.trim());
	}
	if(req.query.updateTime != undefined){	
		(typeof req.query.updateTime != 'string') ? (memberLog.updateTime = req.query.updateTime) : (memberLog.updateTime = req.query.updateTime.trim());
	}
	if(req.query.bak1 != undefined){	
		(typeof req.query.bak1 != 'string') ? (memberLog.bak1 = req.query.bak1) : (memberLog.bak1 = req.query.bak1.trim());
	}
	if(req.query.bak2 != undefined){	
		(typeof req.query.bak2 != 'string') ? (memberLog.bak2 = req.query.bak2) : (memberLog.bak2 = req.query.bak2.trim());
	}
	if(req.query.bak3 != undefined){	
		(typeof req.query.bak3 != 'string') ? (memberLog.bak3 = req.query.bak3) : (memberLog.bak3 = req.query.bak3.trim());
	}
	if(req.query.bak4 != undefined){	
		(typeof req.query.bak4 != 'string') ? (memberLog.bak4 = req.query.bak4) : (memberLog.bak4 = req.query.bak4.trim());
	}
	if(req.query.bak5 != undefined){	
		(typeof req.query.bak5 != 'string') ? (memberLog.bak5 = req.query.bak5) : (memberLog.bak5 = req.query.bak5.trim());
	}
	if(req.query.bak6 != undefined){	
		(typeof req.query.bak6 != 'string') ? (memberLog.bak6 = req.query.bak6) : (memberLog.bak6 = req.query.bak6.trim());
	}
	if(req.query.bak7 != undefined){	
		(typeof req.query.bak7 != 'string') ? (memberLog.bak7 = req.query.bak7) : (memberLog.bak7 = req.query.bak7.trim());
	}
	if(req.query.bak8 != undefined){	
		(typeof req.query.bak8 != 'string') ? (memberLog.bak8 = req.query.bak8) : (memberLog.bak8 = req.query.bak8.trim());
	}
	if(req.query.bak9 != undefined){	
		(typeof req.query.bak9 != 'string') ? (memberLog.bak9 = req.query.bak9) : (memberLog.bak9 = req.query.bak9.trim());
	}
	if(req.query.bak10 != undefined){	
		(typeof req.query.bak10 != 'string') ? (memberLog.bak10 = req.query.bak10) : (memberLog.bak10 = req.query.bak10.trim());
	}
	return memberLog;
};


module.exports = memberLog;
